//
//  RTStatues.swift
//  Weibo
//
//  Created by Brisinga on 16/3/6.
//  Copyright © 2016年 Root. All rights reserved.
//

import UIKit

class RTStatues: NSObject {
    // 微博id
    var id: Int64 = 0
    
    // 创建时间
    var created_at: String?
    
    // 来源
    var source: String?
    
    // 微博内容
    var text: String?
    
    
    // 转发数量
    var reposts_count: Int = 0
    // 评论数量
    var comments_count: Int = 0
    // 点赞数量
    var attitudes_count: Int = 0
    
    
    // 用户信息
    var user: RTUser?
    
    // 转发信息
    var retweeted_status: RTStatues?
    
    // 原创图片信息
    var pic_urls: [RTStatusPictureInfo]?
    
    init(dict: [String: AnyObject]) {
        
        super.init()
        
        setValuesForKeysWithDictionary(dict)
    }
    
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            
            guard let v = value as? [String: AnyObject] else {
                
                return
            }
            
            user = RTUser(dict: v)
            
        }else if key == "retweeted_status" {
        
            
            guard let v = value as? [String: AnyObject] else {
                
                return
            }
        
            retweeted_status = RTStatues(dict: v)
        
        }else if key == "pic_urls" {
        
            
            guard let values = value as? [[String: AnyObject]] else {
            
                return
            }
            
            var tempArr = [RTStatusPictureInfo]()
            
            for v in values {
            
                let picInfo = RTStatusPictureInfo(dict: v)
                
                tempArr.append(picInfo)
            }
            
            self.pic_urls = tempArr
            
            
        }else{
            
             super.setValue(value, forKey: key)
        }
    }
    
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
}
